package purgehelper.dnd;

import java.awt.datatransfer.Transferable;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.TransferHandler;

/**
 *
 * @author leadiv
 */
public class FileTransferHandler extends TransferHandler {

    @Override
    protected Transferable createTransferable(JComponent c) {
        JList list = (JList) c;
        List<File> files = new ArrayList<File>();
        for (Object obj: list.getSelectedValues()) {
            files.add((File)obj);
        }
        return new FileTransferable(files);
    }

    @Override
    public int getSourceActions(JComponent c) {
        return TransferHandler.NONE;
    }

    @Override
    protected void exportDone(JComponent sourc, Transferable data, int action) {
        // TODO: Open the folders containing the files.
        System.out.println("exportDone");
    }
}